<!--
 * @Author: zhangxiangsheng 1026583651@qq.com
 * @Date: 2024-06-25 16:59:08
 * @LastEditors: zhangxiangsheng 1026583651@qq.com
 * @LastEditTime: 2024-06-25 17:27:57
 * @FilePath: \appGly\pages\Cards\Cardedt\components\CardReplace.vue
 * @Description: 
 * 
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
-->
<template>
	<view class="">
		<u-popup :show="show" mode="right" width="100%" :zoom="true">
			<u-navbar title="更换卡号" @leftClick="
          () => {
            show = !show;
          }
        " :autoBack="false"></u-navbar>
			<formz ref="formz" :inputs="inputs" :data="data"></formz>
			<fixedbtn>
				<view class="fixedbtnbox">
					<u-button :loading="loading" type="primary" @click="editfn()">
						{{$z.$t('保存内容')}}
					</u-button>
				</view>
			</fixedbtn>
		</u-popup>
		<zmodal ref="zmodal"></zmodal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				inputs: [{
						label: this.$z.$t("丢失卡号"),
						value: "printidold",
						disabled: "disabled",
					},
					{
						label: this.$z.$t("新卡卡号"),
						value: "printid",
						rule: [{
							required: true,
							message: this.$z.$t("请填写新卡卡号"),
							trigger: "blur",
						}, ],
					},
				],
				data: {},
				list: [{}],
				loading: false,
			};
		},
		methods: {
			init(data) {
				this.data = {
					printidold: data.printid,
					printid: "",
				};
				this.show = true;
			},
			addlist() {
				this.list.push({});
			},
			async editfn() {
				let data = await this.$refs.formz.validate();
				this.$refs.zmodal.init({
					content: this.$z.$t("请确认更换卡号?"),
					showcancel: true,
					confirm: async () => {
						let par = await this.$z.request("/CardReplace", data);
						if (par[0].par == "succeed") {
							this.$refs.zmodal.init({
								content: this.$z.$t("操作成功"),
								confirm: () => {
									// this.init()
									this.$z.back();
								},
							});
						} else {
							this.$u.toast(this.$z.$t("操作失败"));
						}
					},
				});
				console.log(data);
				// this.show = !this.show
			},
		},
	};
</script>

<style lang="scss">
	.fixedbtnbox {
		flex: 1;
		width: 100%;
		padding: 0 30rpx;
	}
</style>